import requset from '@/utils/requset'

// 分类：获取文章分类
export const artGetChannelsService = () => {
  return requset.get('/my/cate/list')
}
// 分类：添加文章分类
export const artAddChannelService = (data) => requset.post('/my/cate/add', data)
// 分类：编辑文章分类
export const artEditChannelService = (data) => requset.put('/my/cate/info', data)
// 分类：删除文章分类
export const artDelChannelService = (id) =>
  requset({
    url: '/my/cate/del',
    params: {
      id,
    },
    method: 'delete',
  })

// 文章：获取文章列表
export const artGetListService = (params) => {
  return requset({
    url: '/my/article/list',
    params: {
      pageNum: params.pageNum,
      pageSize: params.pageSize,
      cateId: params.cateId,
      state: params.state,
    },
  })
}

// 文章：获取某个用户文章总条数
export const artGetAllListService = () => requset({ url: '/my/article/allList' })

// 文章：添加文章
// 注意：data需要是一个formData格式的数据
export const artPublishService = (data) => requset.post('/my/article/add', data)

// 获取文章详情
export const artGetDetailService = (id) => {
  return requset({
    url: '/my/article/info',
    params: { id },
  })
}

// 文章：编辑文章接口
export const artEditService = (data) => {
  return requset({
    method: 'put',
    url: '/my/article/infos',
    data: {
      ...data,
    },
  })
}
